package com.cupdata.zicon.singleton;

import java.io.ObjectStreamException;

/**
 * IoDH单例模式
 */
public class IoDHSingleton {
    static {
        System.out.println("IoDHSingleton 被加载");
    }
    public static IoDHSingleton getInstance(){
        return HolderClass.ioDHSingleton;
    }
    private IoDHSingleton(){}
    private static class HolderClass{
        static {
            System.out.println("HolderClass 被加载");
        }
        private static IoDHSingleton ioDHSingleton = new IoDHSingleton();
    }
    
    // 防止反序列化获取多个对象的漏洞  
    private Object readResolve() throws ObjectStreamException {    
    return  HolderClass.ioDHSingleton;  
        }  
}
